package com.rms.server.Dao;

import com.rms.server.DTO.DishWithIngredientsDTO;
import com.rms.server.Domain.DishIngredientAssociation;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DishIngredientAssociationMapper {
    /**
     * 插入新的菜品与原材料关联信息
     * @param association
     * @return
     */
    //
    @Insert("INSERT INTO Dish_Ingredient_Association (dish_id, ingredient_id, quantity_used) " +
            "VALUES (#{dishId}, #{ingredientId}, #{quantityUsed})")
    int insertDishIngredientAssociation(DishIngredientAssociation association);
//    @Select("SELECT d.dish_id AS dishId, d.dish_name AS dishName, " +
//            "i.ingredient_id AS ingredientId, i.ingredient_name AS ingredientName, " +
//            "da.quantity_used AS quantityUsed " +
//            "FROM Dish d " +
//            "JOIN Dish_Ingredient_Association da ON d.dish_id = da.dish_id " +
//            "JOIN Ingredient i ON da.ingredient_id = i.ingredient_id")
    List<DishWithIngredientsDTO> findAllDishesWithIngredients();


}
